package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Spot;
import cn.wolfcode.wolf2w.query.SpotQueryObject;
import cn.wolfcode.wolf2w.service.ISpotService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("spots")
public class SpotController {

    @Autowired
    private ISpotService spotService;

    // 分页查询
    @GetMapping("/query")
    public Object query(SpotQueryObject qo) {
        Page<Spot> spots = spotService.query(qo);
        return JsonResult.success(spots);
    }

    // 查询全部
    @GetMapping("/list")
    public Object list() {
        List<Spot> list = spotService.list();
        return JsonResult.success(list);
    }

    // 获取某个景点
    @GetMapping("/get")
    public Object get(String id) {
        Spot spot = spotService.get(id);
        return JsonResult.success(spot);
    }
}
